package ordersList;

import interfaces.Order;

import java.util.LinkedList;

import ordersList.OrderList.Type;

public abstract class OrderList {

	private LinkedList<Order> orderList;
	
	public OrderList(){
		orderList = new LinkedList<Order>();
	}
	
	public int getLength(){
		
		return orderList.size();
	}
	
	
	
	public Order getOrder(int orderIndex){
		return orderList.get(orderIndex);
	}
	
	public void addOrder(Order newOrder){
		orderList.add(newOrder);
	}
	
	public int removeOrder(int serverOrderId) {
		int count = 0;
		for (Order order : orderList) {
			if (order.getServerOrderID() == serverOrderId) {
				orderList.remove(order);
				return count;
			}
			count++;
		}
		return -1;
	}
	
	public abstract Order updateOrder(Order updatedOrder);
	
	public enum Type {

		MY_ORDER_LIST,
		PUBLIC_ORDER_LIST
	}

	public abstract Type getType();
	
}
